﻿using M.ShopMachine.Domain;
using M.ShopMachine.Domain.Dto;
using M.ShopMachine.Read.WebApi.Application.Command.WorkshopCommand;
using M.ShopMachine.Repository.Interface;
using MediatR;

namespace M.ShopMachine.Read.WebApi.Application.Handler.WorkshopHandler
{
    public class GetTableWorkshopHandler : IRequestHandler<GetTableWorkshopCommand, List<Workshop>>
    {
        private readonly IWorkshopRepository workshopRepository;

        public GetTableWorkshopHandler(IWorkshopRepository workshopRepository)
        {
            this.workshopRepository = workshopRepository;
        }

        public async Task<List<Workshop>> Handle(GetTableWorkshopCommand request, CancellationToken cancellationToken)
        {
            return await workshopRepository.GetTableWorkShopAsync(request.Number, request.Name, request.State);
        }
    }
}
